﻿SET QUOTED_IDENTIFIER ON
GO
SET ARITHABORT ON
GO
SET NUMERIC_ROUNDABORT OFF
GO
SET CONCAT_NULL_YIELDS_NULL ON
GO
SET ANSI_NULLS ON
GO
SET ANSI_PADDING ON
GO
SET ANSI_WARNINGS ON
GO

-- =============================================
-- Author:		Adrian Kaczmarek
-- Create date: 2013-08-11
-- =============================================
ALTER PROCEDURE [dbo].[bhp_NemoGroupExtensions] (
	@GroupId					INT
)
WITH ENCRYPTION
AS
BEGIN

	SELECT
		*
	FROM
		bht_GroupExtensions
	WHERE
		GroupId = @GroupId
	
END

GO

-- =============================================
-- Author:		Adrian Kaczmarek
-- Create date: 2013-08-11
-- =============================================
CREATE PROCEDURE [dbo].[bhp_NemoGroupExtensionsSave] (
	@GroupId					INT,
	@GroupExtension		NVARCHAR(400),
	@RecordExtension		NVARCHAR(400)
)
WITH ENCRYPTION
AS
BEGIN

	IF EXISTS (SELECT 1 FROM bht_GroupExtensions WHERE GroupId = @GroupId)
		UPDATE bht_GroupExtensions SET GroupExtension = @GroupExtension, RecordExtension = @RecordExtension WHERE GroupId = @GroupId
	ELSE
		INSERT INTO bht_GroupExtensions (GroupId, GroupExtension, RecordExtension) VALUES (@GroupId, @GroupExtension, @RecordExtension)
	
	UPDATE
		n_Tree
	SET
		mtime = GETDATE(),
		muser = 9999999
	WHERE
		id = @GroupId

END
